< previous page page_26 next page >

Page 26
12181-0026a.gif
Figure 1.12.
The Animation control as seen in the
Visual Basic control toolbox.
Putting the Animation control on the form provides your application with a container for the animation sequence to play in. To run the animation, however, you need to create some code to open the .AVI file and start the playback process. The control's Open method is used to open the file specified as the argument for the method. The .AVI files included with VB5 are installed in the \PROGRAM FILES\MICROSOFT VISUAL STUDIO\COMMON\GRAPHICS\VIDEOS directory. After you open the file, you need to execute the Play method to start the animation. The following code shows how to open and then play an animation file:
strAVIFile = C:\Program Files\ MICROSOFT VISUAL
STUDIO\COMMON\GRAPHICS\\VIDEOS\Filecopy.avi
anmAnimation1.Open strAVIFile
anmAnimation1.Play
When you're ready to stop the animation, you simply execute the control's Stop method:
anmAnimation1.Stop
To try out this control, add it and two command buttons to the frmMain form of your demo project (see Figure 1.13). Next, change the names of the command buttons to cmdStart and cmdStop, respectively. Now add the preceding code segments to the appropriate button click routines (see Figure 1.14).
12181-0026b.gif
Figure 1.13.
Working with the Animation control.

 
< previous page page_26 next page >

If you like this book, buy it!